home *** CD-ROM | disk | FTP | other *** search
- #include <stdarg.h>
- #include <stdio.h>
- #include <string.h>
- #include <Timer.h>
- #include "DebugUtils.h"
-
-
-
-
-
- #if DEBUG && CALLTRACE
- #if TARGET_RT_MAC_CFM
- UInt32 CallTrace::fLevel = 0;
- #elif TARGET_CPU_68K
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- static UInt32 GetCallTraceStorage(void);
- #define fLevel *((UInt32*)GetCallTraceStorage())
-
- #ifdef __cplusplus
- }
- #endif
- #endif
- #endif
-
-
-
-
-
- #if DEBUG && CALLTRACE
- CallTrace::CallTrace(char *func)
- {
- dprintf(kDConPrefix "%*s=> %s\n",2 * fLevel,"",func);
- fLevel += 1;
- fName = func;
-
- #if CALLTRACE_TIMER
- Microseconds((UnsignedWide*)&fTime);
- #endif
- }
-
-
-
-
-
- CallTrace::~CallTrace(void)
- {
- #if CALLTRACE_TIMER
- UInt64 time;
- Microseconds((UnsignedWide*)&time);
- #endif
-
- fLevel -= 1;
-
- #if CALLTRACE_TIMER
- dprintf(kDConPrefix "%*s<= %s %.03fms\n",2 * fLevel,"",fName,((double)time - (double)fTime) / 1000.0);
- #else
- dprintf(kDConPrefix "%*s<= %s\n",2 * fLevel,"",fName);
- #endif
- }
- #endif
-
-
-
-
-
- #if DEBUG && CALLTRACE && TARGET_CPU_68K && !CALLTRACE_GLOBALS
- asm UInt32 GetCallTraceStorage(void)
- {
- LEA @Storage,A0
- MOVE.L A0,D0
- RTS
-
- @Storage:
- DC.L 0x00000000
- }
- #endif
-
-
-
-
-
- #if DEBUG
- void DebugStrf(char *format,...)
- {
- Str255 text;
- va_list args;
-
-
- // Convert to pstring.
- va_start(args,format);
- text[0] = vsprintf((char*)&text[1],format,args);
- va_end(args);
-
- DebugStr(text);
- }
-
- void BinaryPrintout(UInt32 val, int numBits)
- {
- int i;
-
- // Output the bit numbers, one every 3 characters
- dprintf(kDConPrefix "Bit ");
- for (i=numBits-1; i>=0; --i)
- dprintf(" %2d",i);
- dprintf("\n");
-
- // Now output the actual bits
- dprintf(kDConPrefix "Value");
- for (i=numBits-1; i>=0; --i)
- dprintf(" %2d", (val>>i)&1);
- dprintf("\n");
- }
- #endif
-
-